package com.tui.image;
import android.content.ContentResolver;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore.Images;
public abstract class BaseImage implements IImage {
    protected ContentResolver   mContentResolver;
    protected Uri 				mUri;
    protected long 				mId;
    private final long 			mDateTaken;

    protected BaseImage(ContentResolver cr,
            long id, Uri uri, long miniThumbMagic,
            long dateTaken) {
        mContentResolver = cr;
        mId = id;
        mUri = uri;
        mDateTaken = dateTaken;
    }

    @Override
    public boolean equals(Object other) {
        if (other == null || !(other instanceof Image)) return false;
        return mUri.equals(((Image) other).mUri);
    }

    @Override
    public int hashCode() {
        return mUri.hashCode();
    }

    public Uri fullSizeImageUri() {
        return mUri;
    }

    public long getDateTaken() {
        return mDateTaken;
    }

    public int getDegreesRotated() {
        return 0;
    }

    public Bitmap miniThumbBitmap() {
        Bitmap b = null;
        try {
            long id = mId;
            b = BitmapManager.instance().getThumbnail(mContentResolver, id,
                    Images.Thumbnails.MICRO_KIND, null, false);
        } catch (Throwable ex) {
            return null;
        }
        if (b != null) {
            b = ImageUtil.rotate(b, getDegreesRotated());
        }
        return b;
    }

    @Override
    public String toString() {
        return mUri.toString();
    }
}
